package com.huangmb.anymark.app.model;

import android.os.Parcel;
import android.os.Parcelable;
import com.alibaba.fastjson.annotation.JSONField;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/4/16 14:02
 */
public class UserMarker implements Parcelable {
    public static final UserPoiItemCreator CREATOR = new UserPoiItemCreator();

    public static final String TYPE_LIVE = "live";
    public static final String TYPE_STORE = "store";
    public static final String TYPE_SCHEDULE = "schedule";
    public static final String TYPE_SCENERY = "scenery";


    private String id;
    private Category mCategory;
    private String mTitle;//标题
    private String mInfo;
    private int mCreateTime;
    private double mLatitude;//纬度
    private double mLongitude;//经度
    private String mAddress;//位置描述
    private String mCoverImage;

    public UserMarker() {

    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(mTitle);
        dest.writeParcelable(mCategory, flags);
        dest.writeDouble(mLatitude);
        dest.writeDouble(mLongitude);
        dest.writeString(mAddress);
        dest.writeString(mInfo);
        dest.writeInt(mCreateTime);
        dest.writeString(mCoverImage);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @JSONField(name = "create_time")
    public int getCreateTime() {
        return mCreateTime;
    }

    @JSONField(name = "create_time")
    public void setCreateTime(int createTime) {
        this.mCreateTime = createTime;
    }

    public String getTitle() {
        return mTitle;
    }

    public void setTitle(String title) {
        this.mTitle = title;
    }

    public void setInfo(String info) {
        this.mInfo = info;
    }

    public String getInfo() {
        return mInfo;
    }

    public Category getCategory() {
        return mCategory;
    }

    public void setCategory(Category category) {
        mCategory = category;
    }

    public String getAddress() {
        return mAddress;
    }

    public void setAddress(String address) {
        this.mAddress = address;
    }

    public double getLatitude() {
        return mLatitude;
    }

    public void setLatitude(double latitude) {
        this.mLatitude = latitude;
    }

    public double getLongitude() {
        return mLongitude;
    }

    public void setLongitude(double longitude) {
        this.mLongitude = longitude;
    }

    public String getCoverImage() {
        return mCoverImage;
    }

    public void setCoverImage(String coverImage) {
        mCoverImage = coverImage;
    }

    private static class UserPoiItemCreator implements Parcelable.Creator<UserMarker> {

        @Override
        public UserMarker createFromParcel(Parcel source) {
            String id = source.readString();
            String title = source.readString();
            Category category = source.readParcelable(Category.class.getClassLoader());
            double latitude = source.readDouble();
            double longitude = source.readDouble();
            String address = source.readString();
            String info = source.readString();
            int time = source.readInt();
            String cover = source.readString();
            UserMarker item = new UserMarker();
            item.id = id;
            item.mTitle = title;
            item.mLatitude = latitude;
            item.mLongitude = longitude;
            item.mAddress = address;
            item.mCategory = category;
            item.mInfo = info;
            item.mCreateTime = time;
            item.mCoverImage = cover;
            return item;
        }

        @Override
        public UserMarker[] newArray(int size) {
            return new UserMarker[size];
        }
    }
}
